home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / Bento / BentoSuppress.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  3.0 KB  |  114 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        BentoSuppress.h
  3.  
  4.     Contains:    Definition of class to temporarily supress fatal Bento errors.
  5.  
  6.     Owned by:    Douglas Hill
  7.  
  8.     Copyright:    © 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>     8/19/96    DH        1376276:OD corrupts document when out of
  13.                                     disk creating draft. Introduced TempCMValue
  14.                                     class to properly set and reset usecount of
  15.                                     values.
  16.          <2>     8/13/96    DM        1376080: new class TempDelayBentoFatalError
  17.                                     prevents fatal errors from being
  18.                                     permanently disabled
  19. */
  20.  
  21. #ifndef _BENTOSUPPRESS_
  22. #define _BENTOSUPPRESS_
  23.  
  24. #ifndef _TEMPOBJ_
  25. #include "TempObj.h"
  26. #endif
  27.  
  28. #ifndef _EXCEPT_
  29. #include "Except.h"
  30. #endif
  31.  
  32. #ifndef _CM_API_
  33. #include <CMAPI.h>
  34. #endif
  35.  
  36. //------------------------------------------------------------------------------
  37. // TempSuppressFatalBentoError
  38. //------------------------------------------------------------------------------
  39.  
  40. // Use this class to supress fatal Bento errors when making Bento API calls.
  41. // Since there is no Bento API for validating a file you wish to open, or that
  42. // creating a new container will fail, we need to make sure that we at least
  43. // won't crash in the process. Make sure that the scope of this object is only
  44. // for the Bento API calls you want to supress. Wrap the instantiation in braces
  45. // to create scope.
  46. //
  47. // For example,
  48. // 
  49. //    void foo(void) {
  50. //    ....
  51.     //    Starts supressing Bento fatal errors.
  52.     //    {
  53.     //        TempSuppressFatalBentoError tempObj;
  54.     //
  55.     //        BentoAPICall1( ...);
  56.     //        BentoAPICall2( ...);
  57.     //    }
  58.     //     ends supressing Bento fatal errors.
  59. //    } 
  60. extern ODBoolean gODSuppressBentoFatalError;
  61.  
  62. class TempSuppressFatalBentoError /*d*/ : Destructo {
  63. public:
  64.     TempSuppressFatalBentoError();
  65.  
  66.     virtual ~TempSuppressFatalBentoError();
  67.     
  68. private:
  69.     ODBoolean fOldSuppress;
  70. };
  71.  
  72. //------------------------------------------------------------------------------
  73. // TempDelayBentoFatalError
  74. //------------------------------------------------------------------------------
  75.  
  76. // Use this class to temporarily delay a fatal Bento error, when it would be very
  77. // bad to call ExitToShell().  For example, while in the drag manager, we do not
  78. // want to call ExitToShell() because this will wedge the machine.
  79.  
  80. extern ODBoolean gODDelayBentoFatalError;
  81.  
  82. class TempDelayBentoFatalError /*d*/ : Destructo {
  83. public:
  84.     TempDelayBentoFatalError();
  85.  
  86.     virtual ~TempDelayBentoFatalError();
  87.     
  88. private:
  89.     ODBoolean fOldDelay;
  90. };
  91.  
  92. //------------------------------------------------------------------------------
  93. // TempCMValue
  94. //------------------------------------------------------------------------------
  95.  
  96. // This class ensures that refcounted Bento values get released.
  97.  
  98. class TempCMValue /*d*/ : Destructo {
  99. private:
  100.     CMValue fValue;
  101.  
  102. public:
  103.     TempCMValue(CMValue v) : fValue(v) { }
  104.     TempCMValue();
  105.  
  106.     virtual ~TempCMValue();
  107.  
  108.     operator CMValue () { return fValue; }
  109.     CMValue operator= (CMValue v) { fValue = v; return v; }
  110.     
  111.     CMValue DontRelease()  { CMValue v = fValue; fValue = kODNULL; return v;}
  112. };
  113.  
  114. #endif